<template>
  <div class="order-item">
    <div class="header">
      <div class="left">
        <image src="/static/images/hotel.png" />
        <span>民宿</span>
      </div>
      <div class="right">
        <span>{{ getStatusName(order.status) }}</span>
        <wd-icon name="delete-thin" size="27rpx" color="#8A8F99"></wd-icon>
      </div>
    </div>

    <div class="content">
      <div @click="to('/pages-sub/hotel/order/index', { id: order.id })">
        <div class="name">{{ order.layoutName }}</div>
        <div class="time">
          {{ dayjs(order.enterDate).format('YYYY-MM-DD') }}至{{
            dayjs(order.leaveDate).format('YYYY-MM-DD')
          }}
        </div>
        <div class="price-box time">
          <span>{{ order.days }}晚 1间 {{ order.hotelName }}</span>
          <div class="price">{{ order.layoutPrice }}</div>
        </div>
      </div>
      <div class="opt" v-if="!order.isComment && order.status === 3">
        <div
          class="btn active"
          @click="to('/pages-sub/hotel/evaluate/add', { id: order.id, layoutId: order.layoutId })"
        >
          去评价
        </div>
      </div>
      <div class="opt" v-if="!order.isComment && order.status === 0">
        <div class="btn active" @click="to('/pages-sub/hotel/order/index', { id: order.id })">
          去支付
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import dayjs from 'dayjs'
import { to } from '@/utils/page'
import { orderStatus } from '@/utils/index'
defineOptions({ name: 'OrderItem' })

defineProps(['order'])

function getStatusName(status) {
  return orderStatus.find((item) => item.value === status).label || status
}
</script>
<style lang="scss" scoped>
.order-item {
  margin-bottom: 26rpx;
  background-color: #fff;
  border-radius: 30rpx;
  .header {
    display: flex;
    align-items: center;
    height: 112rpx;
    padding: 0 24rpx;
    font-size: 27rpx;
    .left {
      display: flex;
      flex: 1;
      align-items: center;
      color: var(--color1);
      image {
        width: 46rpx;
        height: 46rpx;
        margin-right: 8rpx;
      }
    }
    .right {
      display: flex;
      align-items: center;
      color: var(--color4);
      span {
        padding-right: 16rpx;
        margin-right: 16rpx;
        line-height: 1;
        @include border-right(#dfe3e6);
      }
    }
  }

  .content {
    padding: 0 24rpx 36rpx;
    .name {
      font-size: 30rpx;
      line-height: 38rpx;
      color: var(--color1);
    }
    .time {
      margin-top: 20rpx;
      font-size: 25rpx;
      color: var(--color4);
    }
    .price-box {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 8rpx;
      .price {
        font-size: 30rpx;
        font-weight: 700;
        line-height: 36rpx;
        color: var(--color1);
        &::before {
          display: inline-block;
          font-size: 22rpx;
          content: '￥';
        }
      }
    }
    .opt {
      display: flex;
      justify-content: flex-end;
      margin-top: 38rpx;
      .btn {
        width: 146rpx;
        height: 58rpx;
        font-size: 23rpx;
        line-height: 58rpx;
        color: #fff;
        text-align: center;
        background: var(--color1);
        border-radius: 35rpx;
        box-shadow: 0px 17rpx 28rpx rgba(#1f2026, 0.3);
      }
    }
  }
}
</style>
